package com.simple.middle.test.redis.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 项目: pagination
 *
 * 功能描述: 距离枚举
 *
 * @author: WuChengXing
 *
 * @create: 2023-05-30 15:22
 **/
@Getter
@AllArgsConstructor
public enum DistanceUnitEnum {

    /**
     *
     */
    METERS(6378137.0D, "m"),
    KILOMETERS(6378.137D, "km"),
    MILES(3963.191D, "mi"),
    FEET(2.0925646325E7D, "ft")
    ;

    private final Double rate;
    private final String unit;

    public static DistanceUnitEnum getByUnit(String unit) {
        for (DistanceUnitEnum value : values()) {
            if (value.getUnit().equals(unit)) {
                return value;
            }
        }
        return null;
    }

}
